using System;
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;

namespace Socialite
{
	public partial class PlaceDetailsScreen : DialogViewController
	{
		UIBarButtonItem _addToFavoritesButton;

		public PlaceDetailsScreen (Place place) : base (UITableViewStyle.Grouped, null, true)
		{	
			VariableHeightStyledStringElement dayAndTime = new VariableHeightStyledStringElement (
				"Tonight : 10pm - 2am",
				"$" + place.CoverPrice.ToString ()
			);
			dayAndTime.Font = UIFont.FromName (FontName.HelveticaBold, (float)FontSize.ClubEventHeader1);
				
			VariableHeightStyledStringElement crowdType = new VariableHeightStyledStringElement (
				"Crowd: ",
				place.CrowdType.ToString ()
			);
			crowdType.Font = UIFont.FromName (FontName.Helvetica, (float)FontSize.ClubEventHeader2);
			
			VariableHeightStyledStringElement musicType = new VariableHeightStyledStringElement (
				"Music: ",
				place.MusicType.ToString ()
			);
			musicType.Font = UIFont.FromName (FontName.Helvetica, (float)FontSize.ClubEventHeader2);
			
			VariableHeightStyledStringElement dressCode = new VariableHeightStyledStringElement (
				"Dress Code: ",
				place.DressCode.ToString ()
			); 
			dressCode.Font = UIFont.FromName (FontName.Helvetica, (float)FontSize.ClubEventHeader2);
			
			StyledStringElement getOnGuestlist = new StyledStringElement ("Get on Guestlist", 
	          () => 
	          {
				NavigationController.PushViewController(new PromotersScreen(place), true);

				});
			getOnGuestlist.Alignment = UITextAlignment.Center;
			getOnGuestlist.Font = UIFont.FromName (FontName.HelveticaBold, (float)FontSize.ButtonLabel);
			
			Root = new RootElement (place.Name) {
				new Section (){
					new PlaceDetailsElement (place)
				},
				new Section (){
					new PlaceDetailsCheckinElement(place)
				},
				new Section(){
					dayAndTime,
					crowdType,
					musicType,
					dressCode,
					new PlaceImagesElement(place),
					getOnGuestlist
				},
				new Section(){
					new StyledMultilineElement(place.Address){Alignment = UITextAlignment.Center, Font = UIFont.FromName (FontName.Helvetica, (float)FontSize.ClubEventHeader2)},
					new StyledStringElement("Directions to Business", () => {}){Alignment = UITextAlignment.Center, Font = UIFont.FromName (FontName.HelveticaBold, (float)FontSize.ButtonLabel)}
				}
			};
			
			//Control the space between sections...
			this.TableView.SectionFooterHeight = 2;
			this.TableView.SectionHeaderHeight = 2;

			if (_addToFavoritesButton == null)
				_addToFavoritesButton = new UIBarButtonItem (
					"<3",
					UIBarButtonItemStyle.Done,
					(sender, args) => {	});
			
			NavigationItem.SetRightBarButtonItem (_addToFavoritesButton, true);
		}

		public override void ViewDidLoad ()
		{
			//TODO: Set the color of the backround and table...
//			base.ViewDidLoad ();
//			TableView.BackgroundColor = UIColor.Clear;
//			View.BackgroundColor = UIColor.Purple;
		}
	}
}
